package com.leyou.item.web;

import com.leyou.item.Service.SpecificationService;
import com.leyou.item.pojo.SpecParam;
import com.leyou.item.pojo.Specification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("spec")
public class SpecificationController {

    @Autowired
    private SpecificationService specificationService;

    @GetMapping("groups/{cid}")
    public ResponseEntity<List<Specification>> querySpecificationByCategoryId(@PathVariable("cid") Long cid) {
        return ResponseEntity.ok(specificationService.querySpecificatById(cid));
    }

    /**
     * 查询集合数据
     * @param pid 组id
     * @param cid 分类id
     * @return
     */
    @GetMapping("params")
    public ResponseEntity<List<SpecParam>> querySpecificationList(
            @RequestParam(value = "gid",required = false) Long pid,
            @RequestParam(value = "cid",required = false)Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching
            ) {
        return ResponseEntity.ok(specificationService.querySpecificationList(pid,cid,searching));
    }
}
